%number of iterations to converge to given error for different values of d,
%given n
function plottime3(dir,m,n)
prefs=strvcat('pref1','pref5','pref9','pref2','pref4','pref6','pref8','pref10');
files=strvcat('2-28','30-38','40-48','50-58','60-64','66-70','72-76','78-82','84-86','88','90','92','94','96','98','100');
numfiles = length(files(:,1));
numprefs = length(prefs(:,1));
domaincol=4;
resultcol=10;
count = 0;
domain=0;
average=0;
stddev=0;
for p=1:numprefs
  count=0;
  result=0;
  for i=1:numfiles
    %load a file
      alldata=load(strcat(dir,'\m',int2str(m),'_n',int2str(n),'_d',files(i,:),'_',prefs(p,:),'.run.results'));
      numruns=alldata(length(alldata),2)+1;    
      countruns=numruns/2;
      numblocks=alldata(length(alldata),3)+1;
      totexp=floor(length(alldata)/numblocks/numruns);
      for j=1:totexp;
        count=count+1;
        domain(p,count)=alldata(j*numblocks*numruns-1,domaincol);
        for k=1:numruns;
           result(k)= alldata((j-1)*numblocks*numruns+k*numblocks-1,resultcol);
           if result(k) < 0
               result(k)=Inf;
           end;
        end;
        result=sort(result);
        if result(countruns) == Inf
            'error'
        end;
        average(p,count)= mean(result(1:countruns));
        stddev(p,count)= std(result(1:countruns));
     end; 
   end;
end;

%a1 = x0:(x1-x0)/10:x1;


%for a1=.4
%g=1.5
lw=2;
fs=24;
clf;
set(gca,'FontSize',fs);
%set(gca,'XTick',[1000,2000,3000,4000,5000]);
%set(gca,'XTickLabel',{'1k','2k','3k','4k','5k'});
colors='kbgrcmykbgrcmy';
%colors='kkkgggcc';
markers='+o*.xsdv^><ph';
%plot(domain,average,'LineWidth',lw);
for i=1:numprefs
    errorbar(domain(i,:),average(i,:),stddev(i,:),'LineWidth',lw,'Color',colors(i),'Marker',markers(i));
    hold on;
end;
%legend(prefs,'Location','EastOutside');
%ylim([0 200]);
xlim([2 100]);
xlabel('number of bid levels', 'FontSize', fs);
ylabel('number of iterations', 'FontSize', fs);
%title('Percentage of all runs that converge to a given error');
hold off;


name = strcat('./time3_n',int2str(n));
print('-depsc',strcat(name, '.eps'));
%print('-dpdf',strcat(name, '.pdf'));
end

